package org.example.onlinechat.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.onlinechat.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {


    @Select("SELECT * FROM user WHERE username = #{username}")
    List<User> findByUsername(String username);


    @Insert("INSERT INTO user (username, password) " +
            "VALUES (#{username}, #{password})")
    void register(User user);

    @Select("SELECT username FROM user WHERE username = #{name}")
    List<User>  findFromUsername(String name);
}
